package xyz.zyt123.hikvideo.demo;

import xyz.zyt123.hikvideo.bean.Camera;
import xyz.zyt123.hikvideo.util.CameraThread;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zhuyuntao
 */
public class RtspToRtmpDemo {

  private static final Map<String, CameraThread.MyRunnable> jobMap = new HashMap<>();


  public static void main(String[] args) {
    openStream("10001", "192.168.1.64", "admin", "abc369258", "2024-05-08");
  }


  /**
   *
   **/
  private static void openStream(String token, String ip, String username, String password, String openTime) {
    Camera camera = new Camera();
    // 生成token
    String rtsp = "";
    String rtmp = "D:/m3u8/1.m3u8";
    // rtsp://admin:abc369258@192.168.1.64:554/Streaming/Channels/101
    rtsp = "rtsp://" + username + ":" + password + "@" + ip + ":554//Streaming/Channels/101";
    camera.setUsername(username);
    camera.setPassword(password);
    camera.setIp(ip);
    camera.setRtsp(rtsp);
    camera.setOutput(rtmp);
    camera.setOpenTime(openTime);
    camera.setToken(1);
    // 执行任务
    CameraThread.MyRunnable job = new CameraThread.MyRunnable(camera);
    CameraThread.MyRunnable.es.execute(job);
    jobMap.put(token, job);
  }
}
